#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

from dataclasses import dataclass


@dataclass
class JobInfo:
    """
    任务相关参数信息
    """
    copy_id: str
    job_id: str
    # 恢复或者备份
    type: str = None
    pid: str = None
    usr: str = None
    env_path: str = None
    sub_job_id: str = None
    sub_job_type: str = None
    cache_path: str = None
    meta_path: str = None
    meta_rep: dict = None
    cache_rep: dict = None
    data_reps: list = None
    metadata_destination: str = None
    backup_type: int = None
    progress: int = None
    task_status: int = None
    backup_result: int = None
    storage_id: str = None
    protect_env: dict = None
    backup_tool_type: int = None
    res_name: str = None
    nodes: list = None
    pro_obj_extend_info: dict = None
    pro_obj: dict = None
    storage_esn: set = None
    agents: list = None
    failed_agents: list = None
    cluster_agents: list = None
    host_agents: list = None
    open_source_delete: bool = False  # 此次备份是否开启源端重删
    storage_type: str = None
    physical_fine_grained: bool = True

    def log_format(self):
        """
        功能： 日志格式化返回
        """
        return f"pid: {self.pid}, job_id: {self.job_id}, sub_job_id: {self.sub_job_id}"

    def log_usr_env_path_format(self):
        return f"usr: {self.usr}, env_path: {self.env_path}"


@dataclass
class CopyInfo:
    """
    删除的副本信息
    """
    backup_key: str
    copy_id: str
    backup_tool_type: int
    metadata_destination: str
    cache_path: str = None
    meta_path: str = None
    data_reps: list = None
